import click

# However, click DOES NOT provide us -h by default.
# We need to use the context_settings parameter to override the default help_option_names.
CONTEXT_SETTINGS = dict(help_option_names=['-h', '--help'])

# With this we now have two commands (hello, goodbye)
# and a built-in help message.
# Notice that the help message changes when run as an option on the hello command.
@click.group(context_settings=CONTEXT_SETTINGS)
@click.version_option(version='1.0.0')
def greet():
    pass


def greeter(**kwargs):
    output = '{0}, {1}!'.format(kwargs['greeting'],
                                kwargs['name'])
    if kwargs['caps']:
        output = output.upper()
    print(output)


@greet.command() # add command to greet group
@click.argument('name') # add the name argument for command
@click.option('--greeting', default="Hello", help='word to use for the greeting') # add an option with 'Hello' as the default
@click.option('--caps', is_flag=True, help='uppercase the output') # add a flag (is_flag=True)
def hello(**kwargs):
    # print(f'hello, {kwargs["name"]}')
    # # the application logic has been refactored into a single function
    greeter(**kwargs)


@greet.command() # arv[1]: goodbye
@click.argument('name') # arv[2]: dillon
@click.option('--greeting', default='Goodbye', help='word to use for the greeting')
@click.option('--caps', is_flag=True, help='uppercase the output')
def goodbye(**kwargs):
    # print(f'goodbye, {kwargs["name"]}')
    greeter(**kwargs)


if __name__ == "__main__":
    # command
        # hello --> invoke hello()
        # goodbye --> invoke goodbye()
    greet()
